package edu.ynu.se.xiecheng.achitectureclass.nongye.controller;

import edu.ynu.se.xiecheng.achitectureclass.nongye.dao.SoilNitrogenDAO;
import edu.ynu.se.xiecheng.achitectureclass.nongye.entity.SoilNitrogen;
import edu.ynu.se.xiecheng.achitectureclass.nongye.service.SoilNitrogenService;
import edu.ynu.se.xiecheng.achitectureclass.common.controller.LogicController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "土壤含氮量管理")
@RestController
@RequestMapping("/soilnitrogen")
public class SoilNitrogenController extends LogicController<SoilNitrogenService, SoilNitrogenDAO, SoilNitrogen, Integer> {

    @Autowired
    public SoilNitrogenController(SoilNitrogenService soilNitrogenService) {
        super(soilNitrogenService);
    }

    @ApiOperation("根据ID获取土壤含氮量信息")
    @GetMapping("/getsoilnitrogen")
    public SoilNitrogen getSoilNitrogenById(@RequestParam Integer id) {
        return getService().GET(id);
    }

    @ApiOperation("获取所有土壤含氮量信息")
    @GetMapping("/getAllsoilnitrogen")
    public List<SoilNitrogen> getAllSoilNitrogen() {
        return getService().getAll();
    }

    @ApiOperation("创建土壤含氮量记录")
    @PostMapping("/postsoilnitrogen")
    public SoilNitrogen createSoilNitrogen(@RequestBody SoilNitrogen soilNitrogen) {
        return getService().POST(soilNitrogen);
    }

    @ApiOperation("更新土壤含氮量记录")
    @PostMapping("/putsoilnitrogen")
    public SoilNitrogen updateSoilNitrogen(@RequestBody SoilNitrogen soilNitrogen) {
        return getService().PUT(soilNitrogen);
    }

    @ApiOperation("删除土壤含氮量记录")
    @PostMapping("/deletesoilnitrogen")
    public void deleteSoilNitrogen(@RequestBody SoilNitrogen soilNitrogen) {
        getService().DELETE(soilNitrogen);
    }

    @ApiOperation("通过ID删除土壤含氮量记录")
    @GetMapping("/deleteByIdsoilnitrogen")
    public void deleteSoilNitrogenById(@RequestParam Integer id) {
        getService().DELETE(id);
    }
}
